package homework.bank;
import java.util.*;
public class CardsSystem {
    Scanner scanner = new Scanner(System.in);
     Card[] cards=new Card[20];
    void showATMMenu(Card card) {
        int choice2;
        Scanner scanner = new Scanner(System.in);
        do {
            String cardNumber;
            String cardCode;
            double Amount;
            System.out.println("1. Deposit");
            System.out.println("2. Withdraw");
            System.out.println("3. Query");
            System.out.println("4. Exit");
            System.out.print("请输入您的选择: ");
            choice2 = scanner.nextInt();
            switch (choice2) {
                case 1:
                    System.out.println("请输入您的银行卡号: ");
                    cardNumber = scanner.next();
                    System.out.println("请输入您想要存入的金额: ");
                    Amount = scanner.nextDouble();
                    DepositCard.deposit(cardNumber, Amount);
                    CreditCard.deposit(cardNumber, Amount);
                    break;
                case 2:
                    System.out.println("请输入您的银行卡号: ");
                    cardNumber = scanner.next();
                    System.out.println("请输入您的银行卡号密码: ");
                    cardCode = scanner.next();
                    System.out.println("请输入您想要取出的金额: ");
                    Amount = scanner.nextDouble();
                    DepositCard.withdraw(cardNumber, cardCode, Amount);
                    CreditCard.withdraw(cardNumber, cardCode, Amount);
                    break;
                case 3:
                    System.out.print("请输入您要查询的银行卡号: ");
                    cardNumber = scanner.next();
                    query(cardNumber);
                    break;


            }
        } while (choice2 != 4);


    }
     void query(String cardNumber){
        String number;
        System.out.print("请输入您要查询的银行卡号: ");
        number = scanner.next();
        for(int j=0;j<20;j++){
            if(number.equals(cards[j].number)) {
                System.out.println(cards[j]);
                break;
            }
            if(j==19)
                System.out.println("您输入的卡号不存在");
        }
    }
    void pay(){

    }

    public  void main(String[] args)  {
       BankCard[] cards=new BankCard[20];
        Scanner scanner = new Scanner(System.in);
        int choice;
        do {
            System.out.println("1. Open Accounts");
            System.out.println("2. ATM");
            System.out.println("3.pay");
            System.out.println("4. Exit");
            System.out.print("请输入您的选择: ");
            choice = scanner.nextInt();
            int i = 0;
            switch (choice) {
                case 1:
                    while(true) {
                        String number;
                        String code;
                        String type;
                        double balance;
                        System.out.println("请输入您的银行卡号");
                        number = scanner.next();
                        System.out.println("请输入您的密码");
                        code = scanner.next();
                        System.out.println("请选择您要注册的银行卡类型");
                        System.out.println("1.储蓄卡");
                        System.out.println("2.信用卡");
                        int a;
                        a = scanner.nextInt();
                        if (a == 1) {
                            cards[i] = new Card(number, code, "储蓄卡", 0);
                        } else {
                            cards[i] = new Card(number, code, "信用卡", 0);
                        }
                        System.out.println("您还要注册其他账户吗？");
                        System.out.println("1. 继续注册下一个账户");
                        System.out.println("2. 退出");
                        int b;
                        b = scanner.nextInt();
                        i++;
                        if (b == 2)
                            break;
                        if (i >= 20) {
                            System.out.println("账户数已满，您的账户已经不能再注册了");
                            break;
                        }
                    }
                    break;
                case 2:
                    showATMMenu();
                    break;
                case 3:

            }
        }while(choice!=4);
    }
    



}


